import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import vue from '@vitejs/plugin-vue'

// https://vite.dev/config/
export default defineConfig({
  	plugins: [vue()],
	// 路径别名
	resolve: {
		extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.scss', '.css', '.vue'],
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url)),
			'~@': fileURLToPath(new URL('./src', import.meta.url))
		}
	},
	server: {
		port: 8080,
		host: '0.0.0.0',
		open: false,
		proxy: {
			['/api']: {
				target: 'http://192.168.50.79:8080/',
				rewrite: path => path.replace(RegExp(`/api`), ''),
				//开启代理
				changeOrigin: true
			}
		}
	},
})
